//
//  TGMBasePullToRefreshView.m
//  TravelGuideHD
//
//  Created by HanFeng on 2/12/14.
//  Copyright (c) 2014 mafengo Inc. All rights reserved.
//

#import "TGMBasePullToRefreshView.h"

@implementation TGMBasePullToRefreshView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.autoresizingMask = UIViewAutoresizingFlexibleWidth;
        self.backgroundColor = [UIColor clearColor];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    if ([self.refreshViewDelegate respondsToSelector:@selector(pullToRefreshViewDidLayout:)]) {
        [self.refreshViewDelegate pullToRefreshViewDidLayout:self];
    }
    
}

- (void)pullToRefreshView:(SVPullToRefreshView *)pullToRefreshView
          stateDidChanged:(SVPullToRefreshState)state from:(SVPullToRefreshState)previousState
{
    switch (state) {
        case SVPullToRefreshStateLoading:
            break;
        case SVPullToRefreshStateStopped:
            break;
        case SVPullToRefreshStateTriggered:
            break;
        default:
            break;
    }
    
    if ([self.refreshViewDelegate respondsToSelector:@selector(pullToRefreshView:stateDidChanged:from:)]) {
        [self.refreshViewDelegate pullToRefreshView:pullToRefreshView stateDidChanged:state from:previousState];
    }
}

- (void)pullToRefreshView:(SVPullToRefreshView *)pullToRefreshView percentToLoading:(CGFloat)percent
{
    if ([self.refreshViewDelegate respondsToSelector:@selector(pullToRefreshView:percentToLoading:)]) {
        [self.refreshViewDelegate pullToRefreshView:pullToRefreshView percentToLoading:percent];
    }
}

@end
